class Program {
  private _gl: WebGLRenderingContext;
  private _program: WebGLProgram;

  constructor(gl: WebGLRenderingContext) {
    this._gl = gl;
    this._program = gl.createProgram()!;
  }

  shareSource(vertex: string, fragment: string) {
    this._initShader(this._gl.VERTEX_SHADER, vertex);
    this._initShader(this._gl.FRAGMENT_SHADER, fragment);
    this._gl.linkProgram(this._program);
    // #if DEBUG
    this._gl.getProgramInfoLog(this._program);
    // #elif
    // #endif
  }

  private _initShader(type: number, source: string) {
    const shader = this._gl.createShader(type)!;
    this._gl.shaderSource(shader, source);
    this._gl.compileShader(shader);
    this._gl.attachShader(this._program, shader);
  }
}

export default Program;
